[PATCH] D14803: [AArch64] Fix a corner case in BitFeild select
Weiming Zhao via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 18 18:32:59 PST 2015
weimingz created this revision.
weimingz added a reviewer: t.p.northover.
weimingz added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.
When BitWidth is 0 and passed to APInt, APInt will not be happy:
APInt SignificantDstMask = APInt(BitWidth, DstMask);
See https://llvm.org/bugs/show_bug.cgi?id=25571
Looks like then BitWidth is 0, the function should just return true.
http://reviews.llvm.org/D14803
Files:
lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
test/CodeGen/AArch64/bitfield-pr25571.ll
Index: test/CodeGen/AArch64/bitfield-pr25571.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AArch64/bitfield-pr25571.ll
@@ -0,0 +1,23 @@
+; ModuleID = 'bugpoint-reduced-simplified.bc'
+;RUN: llc -verify-machineinstrs < %s | FileCheck %s
+target datalayout = "e-m:e-i64:64-i128:128-n8:16:32:64-S128"
+target triple = "aarch64--linux-gnu"
+
+define i32 @test(i8 %a, i32 %b) {
+; CHECK-LABEL: test
+; CHECK: bfi
+; CHECK: bfi
+; CHECK: bfi
+; CHECK: bfi
+ %conv = zext i8 %a to i32 ; 0 0 0 0 A
+ %shl = shl i32 %b, 8 ; B2 B1 B0 0
+ %or = or i32 %conv, %shl ; B2 B1 B0 A
+ %shl.1 = shl i32 %or, 8 ; B1 B0 A 0
+ %or.1 = or i32 %conv, %shl.1 ; B1 B0 A A
+ %shl.2 = shl i32 %or.1, 8 ; B0 A A 0
+ %or.2 = or i32 %conv, %shl.2 ; B0 A A A
+ %shl.3 = shl i32 %or.2, 8 ; A A A 0
+ %or.3 = or i32 %conv, %shl.3 ; A A A A
+ %shl.4 = shl i32 %or.3, 8 ; A A A 0
+ ret i32 %shl.4
+}
Index: lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
===================================================================
--- lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
+++ lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
@@ -1696,6 +1696,10 @@
"i32 or i64 mask type expected!");
unsigned BitWidth = VT.getSizeInBits() - NumberOfIgnoredHighBits;
+ // trivially true.
+ if (BitWidth == 0)
+ return true;
+
APInt SignificantDstMask = APInt(BitWidth, DstMask);
APInt SignificantBitsToBeInserted = BitsToBeInserted.zextOrTrunc(BitWidth);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14803.40593.patch
Type: text/x-patch
Size: 1543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151119/515c8814/attachment.bin>
More information about the llvm-commits
mailing list