aboutsummaryrefslogtreecommitdiffstats
path: root/powerpc/Asmexpand.ml
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-12-20 10:25:08 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2015-12-20 10:25:08 +0100
commit6423f1293f9bd78dd981dd6a1e8908659d46875f (patch)
tree3f2cdef0e4569663c5cd7afd40bb72eb492c055d /powerpc/Asmexpand.ml
parent366e433a76a8c6def7dbc6f572202728aebfa65f (diff)
downloadcompcert-kvx-6423f1293f9bd78dd981dd6a1e8908659d46875f.tar.gz
compcert-kvx-6423f1293f9bd78dd981dd6a1e8908659d46875f.zip
powerpc/Asmexpand: fix expansion of __builtin_clzll
The original code produces wrong results if res and al are the same register.
Diffstat (limited to 'powerpc/Asmexpand.ml')
-rw-r--r--powerpc/Asmexpand.ml4
1 files changed, 2 insertions, 2 deletions
diff --git a/powerpc/Asmexpand.ml b/powerpc/Asmexpand.ml
index ca166fd1..7af27d20 100644
--- a/powerpc/Asmexpand.ml
+++ b/powerpc/Asmexpand.ml
@@ -363,13 +363,13 @@ let expand_builtin_inline name args res =
emit (Pcntlzw(res, a1))
| "__builtin_clzll", [BA_splitlong(BA(IR ah), BA(IR al))], BR(IR res) ->
let lbl = new_label () in
+ emit (Pcntlzw(GPR0, al));
emit (Pcntlzw(res, ah));
(* less than 32 bits zero? *)
emit (Pcmpwi (res, Cint _32));
emit (Pbf (CRbit_2, lbl));
(* high bits all zero, count bits in low word and increment by 32 *)
- emit (Pcntlzw(res, al));
- emit (Paddi(res, res, Cint _32));
+ emit (Padd(res, res, GPR0));
emit (Plabel lbl)
| "__builtin_cmpb", [BA(IR a1); BA(IR a2)], BR(IR res) ->
emit (Pcmpb (res,a1,a2))