Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[PPC] wrong code generated for ppc_fp128 sign testing #44445

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR45475
Status CONFIRMED
Importance P enhancement
Reported by Carrot (carrot@google.com)
Reported on 2020-04-08 09:59:23 -0700
Last modified on 2020-05-27 18:25:02 -0700
Version trunk
Hardware PC Linux
CC echristo@gmail.com, kit.barton@gmail.com, llvm-bugs@lists.llvm.org, nemanja.i.ibm@gmail.com, yuanfang.chen@sony.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Compile the following code with command line

llc --mtriple=powerpc64le-grtev4-linux-gnu t.ll

define zeroext i1 @ppc128(ppc_fp128 %fp) {
  %v128 = bitcast ppc_fp128 %fp to i128
  %low = trunc i128 %v128 to i64
  %shift = lshr i128 %v128, 64
  %high = trunc i128 %shift to i64
  %c = icmp slt i64 %high, 0           // %c = icmp slt i64 %low, 0
  ret i1 %c
}

LLVM generates:

        li 3, 0
        blr

If I testing the sign of the %low part as in comment, llvm generates the same
code.

In both cases I expect llvm generate bit extraction instructions.
Quuxplusone commented 4 years ago

Hmm... It would appear that the order of elements of BUILD_VECTOR in SimplifyDemandedBits is incorrect.

Quuxplusone commented 4 years ago

Fix in https://reviews.llvm.org/D80683