From: Thomas Lively Date: Mon, 23 Sep 2019 20:04:59 +0000 (+0000) Subject: [WebAssembly] Remove unused memory instructions and patterns X-Git-Tag: llvmorg-11-init~8530 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05a95b208eec5ed1c57287b920310b0de49fc880;p=platform%2Fupstream%2Fllvm.git [WebAssembly] Remove unused memory instructions and patterns Summary: Removes duplicated SIMD loads and store instructions and removes patterns involving GlobalAddresses that were not used in any tests. Reviewers: aheejin, sunfish Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67783 llvm-svn: 372648 --- diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td index fecb895..a9a99d3 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td @@ -71,12 +71,6 @@ class NotifyPatImmOff : def : NotifyPatImmOff; def : NotifyPatImmOff; -def NotifyPatGlobalAddr : - Pat<(i32 (int_wasm_atomic_notify (regPlusGA I32:$addr, - (WebAssemblywrapper tglobaladdr:$off)), - I32:$count)), - (ATOMIC_NOTIFY 0, tglobaladdr:$off, I32:$addr, I32:$count)>; - // Select notifys with just a constant offset. def NotifyPatOffsetOnly : Pat<(i32 (int_wasm_atomic_notify imm:$off, I32:$count)), @@ -105,13 +99,6 @@ def : WaitPatImmOff; def : WaitPatImmOff; def : WaitPatImmOff; -class WaitPatGlobalAddr : - Pat<(i32 (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)), - ty:$exp, I64:$timeout)), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$exp, I64:$timeout)>; -def : WaitPatGlobalAddr; -def : WaitPatGlobalAddr; - // Select wait_i32, ATOMIC_WAIT_I32s with just a constant offset. class WaitPatOffsetOnly : Pat<(i32 (kind imm:$off, ty:$exp, I64:$timeout)), @@ -164,9 +151,6 @@ def : LoadPatImmOff; def : LoadPatImmOff; def : LoadPatImmOff; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - // Select loads with just a constant offset. def : LoadPatOffsetOnly; def : LoadPatOffsetOnly; @@ -257,16 +241,6 @@ def : LoadPatImmOff; def : LoadPatImmOff; // No 32->64 patterns, just use i32.atomic.load and i64.extend_s/i64 -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - // Extending loads with just a constant offset def : LoadPatOffsetOnly; def : LoadPatOffsetOnly; @@ -326,13 +300,6 @@ def : AStorePatImmOff; def : AStorePatImmOff; def : AStorePatImmOff; -class AStorePatGlobalAddr : - Pat<(kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)), - ty:$val), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$val)>; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; - // Select stores with just a constant offset. class AStorePatOffsetOnly : Pat<(kind imm:$off, ty:$val), (inst 0, imm:$off, (CONST_I32 0), ty:$val)>; @@ -387,12 +354,6 @@ def : AStorePatImmOff; def : AStorePatImmOff; def : AStorePatImmOff; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; - // Truncating stores with just a constant offset def : AStorePatOffsetOnly; def : AStorePatOffsetOnly; @@ -513,11 +474,6 @@ class BinRMWPatImmOff : Pat<(ty (kind (operand I32:$addr, imm:$off), ty:$val)), (inst 0, imm:$off, I32:$addr, ty:$val)>; -class BinRMWPatGlobalAddr : - Pat<(ty (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)), - ty:$val)), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$val)>; - // Select binary RMWs with just a constant offset. class BinRMWPatOffsetOnly : Pat<(ty (kind imm:$off, ty:$val)), @@ -538,9 +494,6 @@ multiclass BinRMWPattern; def : BinRMWPatImmOff; - def : BinRMWPatGlobalAddr; - def : BinRMWPatGlobalAddr; - def : BinRMWPatOffsetOnly; def : BinRMWPatOffsetOnly; @@ -635,17 +588,6 @@ multiclass BinRMWTruncExtPattern< def : BinRMWPatImmOff, or_is_add, inst8_64>; def : BinRMWPatImmOff, or_is_add, inst16_64>; - def : BinRMWPatGlobalAddr, inst8_32>; - def : BinRMWPatGlobalAddr, inst16_32>; - def : BinRMWPatGlobalAddr, inst8_64>; - def : BinRMWPatGlobalAddr, inst16_64>; - def : BinRMWPatGlobalAddr, inst32_64>; - - def : BinRMWPatGlobalAddr, inst8_32>; - def : BinRMWPatGlobalAddr, inst16_32>; - def : BinRMWPatGlobalAddr, inst8_64>; - def : BinRMWPatGlobalAddr, inst16_64>; - // Truncating-extending binary RMWs with just a constant offset def : BinRMWPatOffsetOnly, inst8_32>; def : BinRMWPatOffsetOnly, inst16_32>; @@ -745,11 +687,6 @@ class TerRMWPatImmOff : Pat<(ty (kind (operand I32:$addr, imm:$off), ty:$exp, ty:$new)), (inst 0, imm:$off, I32:$addr, ty:$exp, ty:$new)>; -class TerRMWPatGlobalAddr : - Pat<(ty (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)), - ty:$exp, ty:$new)), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$exp, ty:$new)>; - // Select ternary RMWs with just a constant offset. class TerRMWPatOffsetOnly : Pat<(ty (kind imm:$off, ty:$exp, ty:$new)), @@ -770,9 +707,6 @@ multiclass TerRMWPattern; def : TerRMWPatImmOff; - def : TerRMWPatGlobalAddr; - def : TerRMWPatGlobalAddr; - def : TerRMWPatOffsetOnly; def : TerRMWPatOffsetOnly; @@ -859,17 +793,6 @@ multiclass TerRMWTruncExtPattern< def : TerRMWPatImmOff, or_is_add, inst8_64>; def : TerRMWPatImmOff, or_is_add, inst16_64>; - def : TerRMWPatGlobalAddr, inst8_32>; - def : TerRMWPatGlobalAddr, inst16_32>; - def : TerRMWPatGlobalAddr, inst8_64>; - def : TerRMWPatGlobalAddr, inst16_64>; - def : TerRMWPatGlobalAddr, inst32_64>; - - def : TerRMWPatGlobalAddr, inst8_32>; - def : TerRMWPatGlobalAddr, inst16_32>; - def : TerRMWPatGlobalAddr, inst8_64>; - def : TerRMWPatGlobalAddr, inst16_64>; - // Truncating-extending ternary RMWs with just a constant offset def : TerRMWPatOffsetOnly, inst8_32>; def : TerRMWPatOffsetOnly, inst16_32>; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td index 6916b16..eba9b80 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td @@ -37,16 +37,6 @@ def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{ return (~Known0.Zero & ~Known1.Zero) == 0; }]>; -// GlobalAddresses are conceptually unsigned values, so we can also fold them -// into immediate values as long as the add is 'nuw'. -// TODO: We'd like to also match GA offsets but there are cases where the -// register can have a negative value. Find out what more we can do. -def regPlusGA : PatFrag<(ops node:$addr, node:$off), - (add node:$addr, node:$off), - [{ - return N->getFlags().hasNoUnsignedWrap(); -}]>; - // We don't need a regPlusES because external symbols never have constant // offsets folded into them, so we can just use add. @@ -93,15 +83,6 @@ def : LoadPatImmOff; def : LoadPatImmOff; def : LoadPatImmOff; -class LoadPatGlobalAddr : - Pat<(ty (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)))), - (inst 0, tglobaladdr:$off, I32:$addr)>, Requires<[IsNotPIC]>; - -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - // Select loads with just a constant offset. class LoadPatOffsetOnly : Pat<(ty (kind imm:$off)), (inst 0, imm:$off, (CONST_I32 0))>; @@ -167,18 +148,6 @@ def : LoadPatImmOff; def : LoadPatImmOff; def : LoadPatImmOff; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - // Select extending loads with just a constant offset. def : LoadPatOffsetOnly; def : LoadPatOffsetOnly; @@ -224,11 +193,6 @@ def : LoadPatImmOff; def : LoadPatImmOff; def : LoadPatImmOff; def : LoadPatImmOff; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; // Select "don't care" extending loads with just a constant offset. def : LoadPatOffsetOnly; @@ -282,15 +246,6 @@ def : StorePatImmOff; def : StorePatImmOff; def : StorePatImmOff; -class StorePatGlobalAddr : - Pat<(kind ty:$val, - (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off))), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$val)>, Requires<[IsNotPIC]>; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; - // Select stores with just a constant offset. class StorePatOffsetOnly : Pat<(kind ty:$val, imm:$off), (inst 0, imm:$off, (CONST_I32 0), ty:$val)>; @@ -333,12 +288,6 @@ def : StorePatImmOff; def : StorePatImmOff; def : StorePatImmOff; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; - // Select truncating stores with just a constant offset. def : StorePatOffsetOnly; def : StorePatOffsetOnly; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td index 64fb771..24f9e3a 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td @@ -56,7 +56,6 @@ defm "" : SIMDLoad; def : LoadPatNoOffset("LOAD_"#vec_t)>; def : LoadPatImmOff("LOAD_"#vec_t)>; def : LoadPatImmOff("LOAD_"#vec_t)>; -def : LoadPatGlobalAddr("LOAD_"#vec_t)>; def : LoadPatOffsetOnly("LOAD_"#vec_t)>; def : LoadPatGlobalAddrOffOnly("LOAD_"#vec_t)>; } @@ -78,7 +77,6 @@ defm "" : SIMDStore; def : StorePatNoOffset("STORE_"#vec_t)>; def : StorePatImmOff("STORE_"#vec_t)>; def : StorePatImmOff("STORE_"#vec_t)>; -def : StorePatGlobalAddr("STORE_"#vec_t)>; def : StorePatOffsetOnly("STORE_"#vec_t)>; def : StorePatGlobalAddrOffOnly("STORE_"#vec_t)>; }