From 9757ba120661920872bd9b72709730aebd6afe10 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 13 Feb 2014 23:34:13 +0000 Subject: [PATCH] R600/SI: Add a pattern for i32 anyext MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Michel Dänzer git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201370 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/R600/SIInstructions.td | 7 +++++-- test/CodeGen/R600/anyext.ll | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 test/CodeGen/R600/anyext.ll diff --git a/lib/Target/R600/SIInstructions.td b/lib/Target/R600/SIInstructions.td index 0a05f903149..de3f031c48e 100644 --- a/lib/Target/R600/SIInstructions.td +++ b/lib/Target/R600/SIInstructions.td @@ -1838,11 +1838,14 @@ def : Pat < (V_CNDMASK_B32_e64 (i32 0), (i32 -1), $src0) >; -def : Pat < - (i32 (zext i1:$src0)), +class Ext32Pat : Pat < + (i32 (ext i1:$src0)), (V_CNDMASK_B32_e64 (i32 0), (i32 1), $src0) >; +def : Ext32Pat ; +def : Ext32Pat ; + // 1. Offset as 8bit DWORD immediate def : Pat < (SIload_constant i128:$sbase, IMM8bitDWORD:$offset), diff --git a/test/CodeGen/R600/anyext.ll b/test/CodeGen/R600/anyext.ll new file mode 100644 index 00000000000..bbe5d0a393e --- /dev/null +++ b/test/CodeGen/R600/anyext.ll @@ -0,0 +1,14 @@ +; RUN: llc < %s -march=r600 -mcpu=verde -verify-machineinstrs | FileCheck %s + +; CHECK-LABEL: @anyext_i1_i32 +; CHECK: V_CNDMASK_B32_e64 +define void @anyext_i1_i32(i32 addrspace(1)* %out, i32 %cond) { +entry: + %0 = icmp eq i32 %cond, 0 + %1 = zext i1 %0 to i8 + %2 = xor i8 %1, -1 + %3 = and i8 %2, 1 + %4 = zext i8 %3 to i32 + store i32 %4, i32 addrspace(1)* %out + ret void +} -- 2.11.0