[llvm] r360689 - [AMDGPU] Fixed handling of imemdiate i1 literals

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 09:18:00 PDT 2019


Author: rampitec
Date: Tue May 14 09:18:00 2019
New Revision: 360689

URL: http://llvm.org/viewvc/llvm-project?rev=360689&view=rev
Log:
[AMDGPU] Fixed handling of imemdiate i1 literals

This bug was exposed by the rL360395.

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

Added:
    llvm/trunk/test/CodeGen/AMDGPU/xor3-i1-const.ll
Modified:
    llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.cpp

Modified: llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.cpp?rev=360689&r1=360688&r2=360689&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIInstrInfo.cpp Tue May 14 09:18:00 2019
@@ -2523,6 +2523,9 @@ bool SIInstrInfo::mayReadEXEC(const Mach
 
 bool SIInstrInfo::isInlineConstant(const APInt &Imm) const {
   switch (Imm.getBitWidth()) {
+  case 1: // This likely will be a condition code mask.
+    return true;
+
   case 32:
     return AMDGPU::isInlinableLiteral32(Imm.getSExtValue(),
                                         ST.hasInv2PiInlineImm());

Added: llvm/trunk/test/CodeGen/AMDGPU/xor3-i1-const.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/xor3-i1-const.ll?rev=360689&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/xor3-i1-const.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/xor3-i1-const.ll Tue May 14 09:18:00 2019
@@ -0,0 +1,23 @@
+; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
+
+; This test used to crash
+; GCN-LABEL: {{^}}xor3_i1_const:
+; GCN: s_xor_b64 s[{{[0-9:]+}}], s[{{[0-9:]+}}], -1
+; GCN: s_xor_b64 s[{{[0-9:]+}}], s[{{[0-9:]+}}], -1
+define amdgpu_ps float @xor3_i1_const(float inreg %arg1, i32 inreg %arg2) {
+main_body:
+  %tmp26 = fcmp nsz olt float %arg1, 0.000000e+00
+  %tmp28 = call nsz float @llvm.amdgcn.interp.p2(float undef, float undef, i32 0, i32 0, i32 %arg2)
+  %tmp29 = fcmp nsz olt float %arg1, 5.700000e+01
+  %tmp31 = fcmp nsz olt float %tmp28, 0.000000e+00
+  %.demorgan = and i1 %tmp26, %tmp29
+  %tmp34 = xor i1 %.demorgan, true
+  %tmp35 = and i1 %tmp31, %tmp34
+  %tmp36 = xor i1 %tmp35, true
+  %tmp37 = xor i1 %.demorgan, %tmp36
+  %tmp42 = or i1 %tmp37, %tmp35
+  %tmp43 = select i1 %tmp42, float 1.000000e+00, float 0.000000e+00
+  ret float %tmp43
+}
+
+declare float @llvm.amdgcn.interp.p2(float, float, i32, i32, i32)




More information about the llvm-commits mailing list