[llvm] 487f156 - [AMDGPU] Fix setcc combine for i128

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 26 04:43:24 PDT 2021


Author: Neubauer, Sebastian
Date: 2021-10-26T13:39:50+02:00
New Revision: 487f15603e7394658423ab0a0c9afd3d51cd068d

URL: https://github.com/llvm/llvm-project/commit/487f15603e7394658423ab0a0c9afd3d51cd068d
DIFF: https://github.com/llvm/llvm-project/commit/487f15603e7394658423ab0a0c9afd3d51cd068d.diff

LOG: [AMDGPU] Fix setcc combine for i128

The combine asserted if constants could not be represented as uint64_t.
Use APInts to fix this.

Differential Revision: https://reviews.llvm.org/D112416

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SIISelLowering.cpp
    llvm/test/CodeGen/AMDGPU/setcc64.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 51bf50e104b2..683ba697664d 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -10786,7 +10786,7 @@ SDValue SITargetLowering::performSetCCCombine(SDNode *N,
         return LHS.getOperand(0);
     }
 
-    uint64_t CRHSVal = CRHS->getZExtValue();
+    const APInt &CRHSVal = CRHS->getAPIntValue();
     if ((CC == ISD::SETEQ || CC == ISD::SETNE) &&
         LHS.getOpcode() == ISD::SELECT &&
         isa<ConstantSDNode>(LHS.getOperand(1)) &&
@@ -10798,8 +10798,8 @@ SDValue SITargetLowering::performSetCCCombine(SDNode *N,
       // setcc (select cc, CT, CF), CF, ne => cc
       // setcc (select cc, CT, CF), CT, ne => xor cc, -1
       // setcc (select cc, CT, CF), CT, eq => cc
-      uint64_t CT = LHS.getConstantOperandVal(1);
-      uint64_t CF = LHS.getConstantOperandVal(2);
+      const APInt &CT = LHS.getConstantOperandAPInt(1);
+      const APInt &CF = LHS.getConstantOperandAPInt(2);
 
       if ((CF == CRHSVal && CC == ISD::SETEQ) ||
           (CT == CRHSVal && CC == ISD::SETNE))

diff  --git a/llvm/test/CodeGen/AMDGPU/setcc64.ll b/llvm/test/CodeGen/AMDGPU/setcc64.ll
index 4b6591e3d2f3..718cf7015a4a 100644
--- a/llvm/test/CodeGen/AMDGPU/setcc64.ll
+++ b/llvm/test/CodeGen/AMDGPU/setcc64.ll
@@ -260,4 +260,28 @@ entry:
   ret void
 }
 
+; GCN-LABEL: {{^}}i128_sle:
+; GCN: v_cmp_le_u64
+; GCN: v_cmp_le_i64
+; SI: v_cmp_eq_u64
+; VI: s_cmp_eq_u64
+define amdgpu_kernel void @i128_sle(i32 addrspace(1)* %out, i128 %a, i128 %b) #0 {
+entry:
+  %tmp0 = icmp sle i128 %a, %b
+  %tmp1 = sext i1 %tmp0 to i32
+  store i32 %tmp1, i32 addrspace(1)* %out
+  ret void
+}
+
+; GCN-LABEL: {{^}}i128_eq_const:
+; SI: v_cmp_eq_u64
+; VI: s_cmp_eq_u64
+define amdgpu_kernel void @i128_eq_const(i32 addrspace(1)* %out, i128 %a) #0 {
+entry:
+  %tmp0 = icmp eq i128 %a, 85070591730234615865843651857942052992
+  %tmp1 = sext i1 %tmp0 to i32
+  store i32 %tmp1, i32 addrspace(1)* %out
+  ret void
+}
+
 attributes #0 = { nounwind }


        


More information about the llvm-commits mailing list