diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp --- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp +++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp @@ -22,6 +22,7 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST) { const unsigned XLen = ST.getXLen(); const LLT XLenLLT = LLT::scalar(XLen); + const LLT s1 = LLT::scalar(1); using namespace TargetOpcode; @@ -31,11 +32,8 @@ .clampScalar(0, XLenLLT, XLenLLT); getActionDefinitionsBuilder( - {G_UADDE, G_UADDO, G_USUBE, G_USUBO, G_SADDE, G_SADDO, G_SSUBE, G_SSUBO}) - .legalFor({{XLenLLT, XLenLLT}}) - .clampScalar(0, XLenLLT, XLenLLT) - .clampScalar(1, XLenLLT, XLenLLT) - .widenScalarToNextPow2(0); + {G_UADDE, G_UADDO, G_USUBE, G_USUBO}) + .lowerFor({{XLenLLT, s1}}); getActionDefinitionsBuilder({G_ASHR, G_LSHR, G_SHL}) .legalFor({{XLenLLT, XLenLLT}}) diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-add.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-add.mir --- a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-add.mir +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-add.mir @@ -87,12 +87,14 @@ ; CHECK-NEXT: %xlo:_(s32) = COPY $x11 ; CHECK-NEXT: %yhi:_(s32) = COPY $x12 ; CHECK-NEXT: %ylo:_(s32) = COPY $x13 - ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO %xhi, %yhi + ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD %xhi, %yhi + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD]](s32), %yhi + ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD %xlo, %ylo ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[UADDO1]], [[C]] - ; CHECK-NEXT: [[UADDE:%[0-9]+]]:_(s32), [[UADDE1:%[0-9]+]]:_(s32) = G_UADDE %xlo, %ylo, [[AND]] - ; CHECK-NEXT: $x10 = COPY [[UADDO]](s32) - ; CHECK-NEXT: $x11 = COPY [[UADDE]](s32) + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[ADD1]], [[AND]] + ; CHECK-NEXT: $x10 = COPY [[ADD]](s32) + ; CHECK-NEXT: $x11 = COPY [[ADD2]](s32) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11 %xhi:_(s32) = COPY $x10 %xlo:_(s32) = COPY $x11 @@ -119,12 +121,14 @@ ; CHECK-NEXT: %lo1:_(s32) = COPY $x11 ; CHECK-NEXT: %hi2:_(s32) = COPY $x12 ; CHECK-NEXT: %lo2:_(s32) = COPY $x13 - ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO %hi1, %hi2 + ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD %hi1, %hi2 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD]](s32), %hi2 + ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD %lo1, %lo2 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[UADDO1]], [[C]] - ; CHECK-NEXT: [[UADDE:%[0-9]+]]:_(s32), [[UADDE1:%[0-9]+]]:_(s32) = G_UADDE %lo1, %lo2, [[AND]] - ; CHECK-NEXT: $x10 = COPY [[UADDO]](s32) - ; CHECK-NEXT: $x11 = COPY [[UADDE]](s32) + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[ADD1]], [[AND]] + ; CHECK-NEXT: $x10 = COPY [[ADD]](s32) + ; CHECK-NEXT: $x11 = COPY [[ADD2]](s32) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11 %hi1:_(s32) = COPY $x10 %lo1:_(s32) = COPY $x11 @@ -150,16 +154,20 @@ ; CHECK-NEXT: %hi2:_(s32) = COPY $x13 ; CHECK-NEXT: %mid2:_(s32) = COPY $x14 ; CHECK-NEXT: %lo2:_(s32) = COPY $x15 - ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO %hi1, %hi2 + ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD %hi1, %hi2 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD]](s32), %hi2 + ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD %mid1, %mid2 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[UADDO1]], [[C]] - ; CHECK-NEXT: [[UADDE:%[0-9]+]]:_(s32), [[UADDE1:%[0-9]+]]:_(s32) = G_UADDE %mid1, %mid2, [[AND]] + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[ADD1]], [[AND]] + ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[ADD2]](s32), %mid1 + ; CHECK-NEXT: [[ADD3:%[0-9]+]]:_(s32) = G_ADD %lo1, %lo2 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[UADDE1]], [[C1]] - ; CHECK-NEXT: [[UADDE2:%[0-9]+]]:_(s32), [[UADDE3:%[0-9]+]]:_(s32) = G_UADDE %lo1, %lo2, [[AND1]] - ; CHECK-NEXT: $x10 = COPY [[UADDO]](s32) - ; CHECK-NEXT: $x11 = COPY [[UADDE]](s32) - ; CHECK-NEXT: $x12 = COPY [[UADDE2]](s32) + ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ICMP1]], [[C1]] + ; CHECK-NEXT: [[ADD4:%[0-9]+]]:_(s32) = G_ADD [[ADD3]], [[AND1]] + ; CHECK-NEXT: $x10 = COPY [[ADD]](s32) + ; CHECK-NEXT: $x11 = COPY [[ADD2]](s32) + ; CHECK-NEXT: $x12 = COPY [[ADD4]](s32) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12 %hi1:_(s32) = COPY $x10 %mid1:_(s32) = COPY $x11 diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-sub.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-sub.mir --- a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-sub.mir +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-sub.mir @@ -87,12 +87,14 @@ ; CHECK-NEXT: %xlo:_(s32) = COPY $x11 ; CHECK-NEXT: %yhi:_(s32) = COPY $x12 ; CHECK-NEXT: %ylo:_(s32) = COPY $x13 - ; CHECK-NEXT: [[USUBO:%[0-9]+]]:_(s32), [[USUBO1:%[0-9]+]]:_(s32) = G_USUBO %xhi, %yhi + ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB %xhi, %yhi + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), %xhi(s32), %yhi + ; CHECK-NEXT: [[SUB1:%[0-9]+]]:_(s32) = G_SUB %xlo, %ylo ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[USUBO1]], [[C]] - ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s32), [[USUBE1:%[0-9]+]]:_(s32) = G_USUBE %xlo, %ylo, [[AND]] - ; CHECK-NEXT: $x10 = COPY [[USUBO]](s32) - ; CHECK-NEXT: $x11 = COPY [[USUBE]](s32) + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[SUB2:%[0-9]+]]:_(s32) = G_SUB [[SUB1]], [[AND]] + ; CHECK-NEXT: $x10 = COPY [[SUB]](s32) + ; CHECK-NEXT: $x11 = COPY [[SUB2]](s32) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11 %xhi:_(s32) = COPY $x10 %xlo:_(s32) = COPY $x11 @@ -119,12 +121,14 @@ ; CHECK-NEXT: %lo1:_(s32) = COPY $x11 ; CHECK-NEXT: %hi2:_(s32) = COPY $x12 ; CHECK-NEXT: %lo2:_(s32) = COPY $x13 - ; CHECK-NEXT: [[USUBO:%[0-9]+]]:_(s32), [[USUBO1:%[0-9]+]]:_(s32) = G_USUBO %hi1, %hi2 + ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB %hi1, %hi2 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), %hi1(s32), %hi2 + ; CHECK-NEXT: [[SUB1:%[0-9]+]]:_(s32) = G_SUB %lo1, %lo2 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[USUBO1]], [[C]] - ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s32), [[USUBE1:%[0-9]+]]:_(s32) = G_USUBE %lo1, %lo2, [[AND]] - ; CHECK-NEXT: $x10 = COPY [[USUBO]](s32) - ; CHECK-NEXT: $x11 = COPY [[USUBE]](s32) + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[SUB2:%[0-9]+]]:_(s32) = G_SUB [[SUB1]], [[AND]] + ; CHECK-NEXT: $x10 = COPY [[SUB]](s32) + ; CHECK-NEXT: $x11 = COPY [[SUB2]](s32) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11 %hi1:_(s32) = COPY $x10 %lo1:_(s32) = COPY $x11 @@ -150,16 +154,24 @@ ; CHECK-NEXT: %hi2:_(s32) = COPY $x13 ; CHECK-NEXT: %mid2:_(s32) = COPY $x14 ; CHECK-NEXT: %lo2:_(s32) = COPY $x15 - ; CHECK-NEXT: [[USUBO:%[0-9]+]]:_(s32), [[USUBO1:%[0-9]+]]:_(s32) = G_USUBO %hi1, %hi2 + ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB %hi1, %hi2 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), %hi1(s32), %hi2 + ; CHECK-NEXT: [[SUB1:%[0-9]+]]:_(s32) = G_SUB %mid1, %mid2 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[USUBO1]], [[C]] - ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s32), [[USUBE1:%[0-9]+]]:_(s32) = G_USUBE %mid1, %mid2, [[AND]] + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[SUB2:%[0-9]+]]:_(s32) = G_SUB [[SUB1]], [[AND]] + ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), %mid1(s32), %mid2 + ; CHECK-NEXT: [[ICMP2:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), %mid1(s32), %mid2 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[USUBE1]], [[C1]] - ; CHECK-NEXT: [[USUBE2:%[0-9]+]]:_(s32), [[USUBE3:%[0-9]+]]:_(s32) = G_USUBE %lo1, %lo2, [[AND1]] - ; CHECK-NEXT: $x10 = COPY [[USUBO]](s32) - ; CHECK-NEXT: $x11 = COPY [[USUBE]](s32) - ; CHECK-NEXT: $x12 = COPY [[USUBE2]](s32) + ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ICMP1]], [[C1]] + ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND1]](s32), [[ICMP]], [[ICMP2]] + ; CHECK-NEXT: [[SUB3:%[0-9]+]]:_(s32) = G_SUB %lo1, %lo2 + ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 + ; CHECK-NEXT: [[AND2:%[0-9]+]]:_(s32) = G_AND [[SELECT]], [[C2]] + ; CHECK-NEXT: [[SUB4:%[0-9]+]]:_(s32) = G_SUB [[SUB3]], [[AND2]] + ; CHECK-NEXT: $x10 = COPY [[SUB]](s32) + ; CHECK-NEXT: $x11 = COPY [[SUB2]](s32) + ; CHECK-NEXT: $x12 = COPY [[SUB4]](s32) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12 %hi1:_(s32) = COPY $x10 %mid1:_(s32) = COPY $x11 diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-add.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-add.mir --- a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-add.mir +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-add.mir @@ -107,12 +107,14 @@ ; CHECK-NEXT: %x01:_(s64) = COPY $x11 ; CHECK-NEXT: %y00:_(s64) = COPY $x12 ; CHECK-NEXT: %y01:_(s64) = COPY $x13 - ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s64) = G_UADDO %x00, %y00 + ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD %x00, %y00 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), [[ADD]](s64), %y00 + ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD %x01, %y01 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[UADDO1]], [[C]] - ; CHECK-NEXT: [[UADDE:%[0-9]+]]:_(s64), [[UADDE1:%[0-9]+]]:_(s64) = G_UADDE %x01, %y01, [[AND]] - ; CHECK-NEXT: $x10 = COPY [[UADDO]](s64) - ; CHECK-NEXT: $x11 = COPY [[UADDE]](s64) + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[ADD2:%[0-9]+]]:_(s64) = G_ADD [[ADD1]], [[AND]] + ; CHECK-NEXT: $x10 = COPY [[ADD]](s64) + ; CHECK-NEXT: $x11 = COPY [[ADD2]](s64) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11 %x00:_(s64) = COPY $x10 %x01:_(s64) = COPY $x11 @@ -139,12 +141,14 @@ ; CHECK-NEXT: %lo1:_(s64) = COPY $x11 ; CHECK-NEXT: %hi2:_(s64) = COPY $x12 ; CHECK-NEXT: %lo2:_(s64) = COPY $x13 - ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s64) = G_UADDO %hi1, %hi2 + ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD %hi1, %hi2 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), [[ADD]](s64), %hi2 + ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD %lo1, %lo2 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[UADDO1]], [[C]] - ; CHECK-NEXT: [[UADDE:%[0-9]+]]:_(s64), [[UADDE1:%[0-9]+]]:_(s64) = G_UADDE %lo1, %lo2, [[AND]] - ; CHECK-NEXT: $x10 = COPY [[UADDO]](s64) - ; CHECK-NEXT: $x11 = COPY [[UADDE]](s64) + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[ADD2:%[0-9]+]]:_(s64) = G_ADD [[ADD1]], [[AND]] + ; CHECK-NEXT: $x10 = COPY [[ADD]](s64) + ; CHECK-NEXT: $x11 = COPY [[ADD2]](s64) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11 %hi1:_(s64) = COPY $x10 %lo1:_(s64) = COPY $x11 @@ -170,16 +174,20 @@ ; CHECK-NEXT: %hi2:_(s64) = COPY $x13 ; CHECK-NEXT: %mid2:_(s64) = COPY $x14 ; CHECK-NEXT: %lo2:_(s64) = COPY $x15 - ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s64) = G_UADDO %hi1, %hi2 + ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD %hi1, %hi2 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), [[ADD]](s64), %hi2 + ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD %mid1, %mid2 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[UADDO1]], [[C]] - ; CHECK-NEXT: [[UADDE:%[0-9]+]]:_(s64), [[UADDE1:%[0-9]+]]:_(s64) = G_UADDE %mid1, %mid2, [[AND]] + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[ADD2:%[0-9]+]]:_(s64) = G_ADD [[ADD1]], [[AND]] + ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), [[ADD2]](s64), %mid1 + ; CHECK-NEXT: [[ADD3:%[0-9]+]]:_(s64) = G_ADD %lo1, %lo2 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 - ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[UADDE1]], [[C1]] - ; CHECK-NEXT: [[UADDE2:%[0-9]+]]:_(s64), [[UADDE3:%[0-9]+]]:_(s64) = G_UADDE %lo1, %lo2, [[AND1]] - ; CHECK-NEXT: $x10 = COPY [[UADDO]](s64) - ; CHECK-NEXT: $x11 = COPY [[UADDE]](s64) - ; CHECK-NEXT: $x12 = COPY [[UADDE2]](s64) + ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[ICMP1]], [[C1]] + ; CHECK-NEXT: [[ADD4:%[0-9]+]]:_(s64) = G_ADD [[ADD3]], [[AND1]] + ; CHECK-NEXT: $x10 = COPY [[ADD]](s64) + ; CHECK-NEXT: $x11 = COPY [[ADD2]](s64) + ; CHECK-NEXT: $x12 = COPY [[ADD4]](s64) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12 %hi1:_(s64) = COPY $x10 %mid1:_(s64) = COPY $x11 diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-sub.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-sub.mir --- a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-sub.mir +++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-sub.mir @@ -107,12 +107,14 @@ ; CHECK-NEXT: %x01:_(s64) = COPY $x11 ; CHECK-NEXT: %y00:_(s64) = COPY $x12 ; CHECK-NEXT: %y01:_(s64) = COPY $x13 - ; CHECK-NEXT: [[USUBO:%[0-9]+]]:_(s64), [[USUBO1:%[0-9]+]]:_(s64) = G_USUBO %x00, %y00 + ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB %x00, %y00 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), %x00(s64), %y00 + ; CHECK-NEXT: [[SUB1:%[0-9]+]]:_(s64) = G_SUB %x01, %y01 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[USUBO1]], [[C]] - ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s64), [[USUBE1:%[0-9]+]]:_(s64) = G_USUBE %x01, %y01, [[AND]] - ; CHECK-NEXT: $x10 = COPY [[USUBO]](s64) - ; CHECK-NEXT: $x11 = COPY [[USUBE]](s64) + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[SUB2:%[0-9]+]]:_(s64) = G_SUB [[SUB1]], [[AND]] + ; CHECK-NEXT: $x10 = COPY [[SUB]](s64) + ; CHECK-NEXT: $x11 = COPY [[SUB2]](s64) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11 %x00:_(s64) = COPY $x10 %x01:_(s64) = COPY $x11 @@ -139,12 +141,14 @@ ; CHECK-NEXT: %lo1:_(s64) = COPY $x11 ; CHECK-NEXT: %hi2:_(s64) = COPY $x12 ; CHECK-NEXT: %lo2:_(s64) = COPY $x13 - ; CHECK-NEXT: [[USUBO:%[0-9]+]]:_(s64), [[USUBO1:%[0-9]+]]:_(s64) = G_USUBO %hi1, %hi2 + ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB %hi1, %hi2 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), %hi1(s64), %hi2 + ; CHECK-NEXT: [[SUB1:%[0-9]+]]:_(s64) = G_SUB %lo1, %lo2 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[USUBO1]], [[C]] - ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s64), [[USUBE1:%[0-9]+]]:_(s64) = G_USUBE %lo1, %lo2, [[AND]] - ; CHECK-NEXT: $x10 = COPY [[USUBO]](s64) - ; CHECK-NEXT: $x11 = COPY [[USUBE]](s64) + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[SUB2:%[0-9]+]]:_(s64) = G_SUB [[SUB1]], [[AND]] + ; CHECK-NEXT: $x10 = COPY [[SUB]](s64) + ; CHECK-NEXT: $x11 = COPY [[SUB2]](s64) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11 %hi1:_(s64) = COPY $x10 %lo1:_(s64) = COPY $x11 @@ -170,16 +174,24 @@ ; CHECK-NEXT: %hi2:_(s64) = COPY $x13 ; CHECK-NEXT: %mid2:_(s64) = COPY $x14 ; CHECK-NEXT: %lo2:_(s64) = COPY $x15 - ; CHECK-NEXT: [[USUBO:%[0-9]+]]:_(s64), [[USUBO1:%[0-9]+]]:_(s64) = G_USUBO %hi1, %hi2 + ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB %hi1, %hi2 + ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), %hi1(s64), %hi2 + ; CHECK-NEXT: [[SUB1:%[0-9]+]]:_(s64) = G_SUB %mid1, %mid2 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 - ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[USUBO1]], [[C]] - ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s64), [[USUBE1:%[0-9]+]]:_(s64) = G_USUBE %mid1, %mid2, [[AND]] + ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ICMP]], [[C]] + ; CHECK-NEXT: [[SUB2:%[0-9]+]]:_(s64) = G_SUB [[SUB1]], [[AND]] + ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(s64) = G_ICMP intpred(eq), %mid1(s64), %mid2 + ; CHECK-NEXT: [[ICMP2:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), %mid1(s64), %mid2 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 - ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[USUBE1]], [[C1]] - ; CHECK-NEXT: [[USUBE2:%[0-9]+]]:_(s64), [[USUBE3:%[0-9]+]]:_(s64) = G_USUBE %lo1, %lo2, [[AND1]] - ; CHECK-NEXT: $x10 = COPY [[USUBO]](s64) - ; CHECK-NEXT: $x11 = COPY [[USUBE]](s64) - ; CHECK-NEXT: $x12 = COPY [[USUBE2]](s64) + ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[ICMP1]], [[C1]] + ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND1]](s64), [[ICMP]], [[ICMP2]] + ; CHECK-NEXT: [[SUB3:%[0-9]+]]:_(s64) = G_SUB %lo1, %lo2 + ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 1 + ; CHECK-NEXT: [[AND2:%[0-9]+]]:_(s64) = G_AND [[SELECT]], [[C2]] + ; CHECK-NEXT: [[SUB4:%[0-9]+]]:_(s64) = G_SUB [[SUB3]], [[AND2]] + ; CHECK-NEXT: $x10 = COPY [[SUB]](s64) + ; CHECK-NEXT: $x11 = COPY [[SUB2]](s64) + ; CHECK-NEXT: $x12 = COPY [[SUB4]](s64) ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12 %hi1:_(s64) = COPY $x10 %mid1:_(s64) = COPY $x11